package nju.mscs.businesslogic;

import java.util.ArrayList;
import java.util.HashMap;

import nju.mscs.data.object.*;

public class GOG implements GetOutGift{
	private String id;
	private Database db;
	private ArrayList<VipConsumer> birthGift;
	private ArrayList<VipConsumer> pointsGift;
	private HashMap<String,String> vip_gift=new HashMap<String,String>();
//	private ArrayList<String> vipList=new ArrayList<String>();
//	private ArrayList<String> giftList=new ArrayList<String>();
	public GOG(){
		db=LogIn.db;
		birthGift=BackStage.birthGift;
		pointsGift=BackStage.pointsGift;
	}
	@Override
	public String[][] showList() {
		int n=birthGift.size();
		int m=pointsGift.size();
		String[][] show=new String[n+m][3];
		int i=0;
		for(VipConsumer vip:birthGift){
			show[i][0]=vip.getId();
			show[i][1]=vip.getName();
			show[i][2]="生日";
			i++;
		}
		for(VipConsumer vip:pointsGift){
			show[i][0]=vip.getId();
			show[i][1]=vip.getName();
			int points=0;
			switch(vip.getPointGift()){
			case 0:
				points=BackStage.pointsLevel1;
				break;
			case 1:
				points=BackStage.pointsLevel2;
				break;
			case 2:
				points=BackStage.pointsLevel3;
				break;
			default:
				points=BackStage.pointslift*(vip.getPointGift()-1);
			}
			show[i][2]="达到"+points+"积分";
			i++;
		}
		// TODO Auto-generated method stub
		return show;
	}
	@Override
	public boolean storeGG(String[][] inf) {
		// TODO Auto-generated method stub
		for(int i=0;i<inf.length/2;i++){
			VipConsumer vip=db.searchVipConsumerById(inf[i][0]);
			vip.addGift(inf[i][1]);
			if(birthGift.contains(vip))
				vip.setBirthGift(true);
			else if(pointsGift.contains(vip))
				vip.addPointGift();		
		}
		takeReceipt();
		return true;
	}
	private void takeReceipt() {
		
	}
    
}
